GINO Graphics Suite - GINO v9.0  

Use of External Files

Several GINO routines need to reference external files in order to either direct graphics commands to a file, reading or writing metafiles or directing diagnostics information. For historical reasons many of these routines require an identifier of an already opened file.

Two routines are provided to open and close such files in a language independent way:

file=gFopen(name,mode)
istat=gFclose(file)

In the C interface, the function gFopen() returns a pointer to a special file structure called 'GFILE', which is required by all the file handling routines in GINO. The routine has the same arguments as the standard C routine fopen. The file can be closed with the routine gFclose(). If a NULL pointer is used, standard input or standard output is used as appropriate to the GINO routine.

When using the Fortran 90 interface, the function gFopen() returns an integer file unit number of a file opened by the GINO library. This prevents the possible problem of a file being opened by a GINO application (using the OPEN statement) being unknown to the GINO library which can occur if the GINO library is being used as a DLL.

The following example shows how to direct error/tracer output and PostScript output to two named files within a GINO program:

[C/C++]
#include <gino-c.h>
GFILE *erfile
main()
{
   gOpenGino();
/* open file for error and tracer output */
   erfile = gFopen("error.out","w");
   gSetErrorFile(erfile);
/* nominate postscript driver */
   gEps(1,0.0,0.0,297.0,210.0,297.0,210.0);
/* direct formatted output to file */
   gSetDeviceFilename("triangle.eps",-1);
/* draw triangle */
   triangle(20.0,20.0,25.0);
/* close device and file */
   gCloseDevice();
   gFclose(erfile);
}
[F90]
use gino_f90
integer erunit
   call gOpenGino
! open file for error and tracer output
   erunit=gFopen('error.out',GWRITE)
   call gSetErrorFile(erunit)
! nominate postscript driver
   call gEps(1,0.0,0.0,297.0,210.0,297.0,210.0)
! direct formatted output to file
   call gSetDeviceFilename('triangle.eps',-1)
! draw triangle
   call triangle(20.0,20.0,25.0)
! close device and file
   call gCloseDevice
   istat=gFclose(erunit)
   stop
   end